Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preview): allow null as valid cache/memo value for preview fields #7551

Merged
merged 3 commits into from
Sep 26, 2024

Conversation

bjoerge
Copy link
Member

@bjoerge bjoerge commented Sep 26, 2024

Description

When previewing a document field, we keep a memo of the latest value so that when resubscribing to the same document later starts by emitting the latest known value (before we fetch from the server).

However, there was a flaw in the current implementation causing unneccessary loading states to appear in the studio:

In short: We assumed the memo being null meant that it hadn't been set, but in many cases it’s being explicitly set to null because we get null back from fetching the fields from the server.

This PR fixes the issue by instead treating undefined as "memo not being set".

What to review

See code changes + added tests

Testing

Added a unit test covering this particular case.

Notes for release

  • Fixes a few cases of unnecessary loading states appearing in the Studio

Copy link

vercel bot commented Sep 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
page-building-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 11:31am
performance-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 11:31am
test-compiled-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 11:31am
test-next-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 11:31am
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 26, 2024 11:31am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Sep 26, 2024 11:31am

Copy link
Contributor

No changes to documentation

pedrobonamin
pedrobonamin previously approved these changes Sep 26, 2024
Copy link
Contributor

github-actions bot commented Sep 26, 2024

Component Testing Report Updated Sep 26, 2024 11:34 AM (UTC)

✅ All Tests Passed -- expand for details
File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 30s 6 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 37s 11 7 0
formBuilder/inputs/PortableText/copyPaste/CopyPasteFields.spec.tsx ✅ Passed (Inspect) 0s 0 12 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/DisableFocusAndUnset.spec.tsx ✅ Passed (Inspect) 10s 3 0 0
formBuilder/inputs/PortableText/DragAndDrop.spec.tsx ✅ Passed (Inspect) 2m 33s 1 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 44s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 41s 21 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 15s 18 0 0
formBuilder/inputs/PortableText/PresenceCursors.spec.tsx ✅ Passed (Inspect) 8s 3 9 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 26s 9 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 17s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 35s 12 0 0
formBuilder/tree-editing/TreeEditing.spec.tsx ✅ Passed (Inspect) 0s 0 3 0
formBuilder/tree-editing/TreeEditingNestedObjects.spec.tsx ✅ Passed (Inspect) 0s 0 3 0

Copy link
Contributor

@pedrobonamin pedrobonamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks for this !

@bjoerge bjoerge added this pull request to the merge queue Sep 26, 2024
Merged via the queue into next with commit 7b9b556 Sep 26, 2024
50 checks passed
@bjoerge bjoerge deleted the fix-preview-value-memo branch September 26, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants